package T5_why_neeed_synchronized;

public class T5_why_neeed_synchronized {
	public static void main(String[] args) {
		System.out.println(Thread.currentThread().getName());
		new MyThread("lang1").start();
		new MyThread("xian2").start();
	}
}

class MyThread extends Thread{
	public MyThread(String name) {    
        super(name);    
    }    
  
    public synchronized void run() {    
        for(int i = 0;i<5;i++){    
            System.out.println(this.getName()+" :"+i);    
            try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
        }    
    }    
}